<?php
include_once('admin_global.php');
bn_include_lib('bn_jquery');
$theme->add_block('body');
$grid=new bn_grid();
$ui=bn_userinfo::getInstance();

$grid->page_size=20;
$grid->paging->enable=true;
$grid->paging->caption=$lang[75];
$grid->paging->cssclass='button';
$grid->header_show=true;

$cuser=new column;
$cuser->field_name='user';
$cuser->caption=$lang[1];
$grid->columns->append($cuser);

$cip=new column;
$cip->field_name='ip';
$cip->caption=$lang[20];
$grid->columns->append($cip);

$cpage=new column;
$cpage->field_name='page';
$cpage->caption=$lang[51];
$grid->columns->append($cpage);

$ctimeid=new column;
$ctimeid->field_name='timein';
$ctimeid->caption=$lang[52];
$grid->columns->append($ctimeid);

$ctimeout=new column;
$ctimeout->field_name='timeout';
$ctimeout->caption=$lang[53];
$grid->columns->append($ctimeout);

$col='';
$val='';
if(isset($_POST['submit']))
{
    $col=$_POST['type'];
    if($col=='date')
    $col='date(timein)';
    $val=$_POST['search'];
    die($grid->show($ui->select_alluinfo($col,$val)->fetch()));
}

if(isset($_POST['cmd']))
{
    $col=$_POST['type'];
    if($col=='date')
    $col='date(timein)';
    $val=$_POST['search'];
    die($grid->show($ui->select_alluinfo($col,$val)->fetch(),$_POST['grid1_page']));    
}

?>
<div id="search_div">
<label><?php echo $lang[54] ?></label>
<select size="1" name="type" id="type" class="select">
	<option value="user">user</option>
	<option value="ip">ip</option>
	<option value="date">date</option>
</select>
<input type="text" size="25" autocomplete="on" name="search" id="search" class="input-text"/>
<input type="submit" name="submit" id="submit" value="<?php echo $lang[26] ?>" class="button"/>
<script type="text/javascript">
$('#submit').live('click',function(){
    $.post(window.location.href,{submit:'submit',type:$('#type').val(),search:$('#search').val()},function(data){$('#show').html(data)});
});
</script>
<div id="show">
<?php
$grid->show($ui->select_alluinfo()->fetch());
$theme->add_script($grid->command_script('#search_div')) ;
?>
</div>
</div>
<?php
$theme->render();	
?>